from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class User(AbstractUser):
    phone=models.CharField(max_length=11)
    age=models.IntegerField(max_length=5)
    code=models.CharField(max_length=6)

class Code(models.Model):
    code=models.CharField(max_length=6)
    phone=models.CharField(max_length=11)
    created=models.DateTimeField(auto_now_add=True)

class Token(models.Model):
    key=models.CharField(max_length=32)
    user=models.OneToOneField(User,on_delete=True)
    created=models.DateTimeField(auto_now_add=True)

class Type(models.Model):
    type=models.CharField(max_length=20)
    def __str__(self):
        return self.type

class Book(models.Model):
    name=models.CharField(max_length=30)
    type=models.ForeignKey(Type,on_delete=True)

